using UnityEngine;
using System.Collections;

public class ShieldMove : MonoBehaviour 
{
	public int shieldSpeed = 200;
	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		PlayerMove ();
	}
	
	void PlayerMove()
	{
		Vector3 moveDirection = Vector3.zero;
		Vector3 newPosition = Vector3.zero;
		
		if(Input.GetKey(KeyCode.RightArrow)) moveDirection.x += 1;
		if(Input.GetKey(KeyCode.LeftArrow)) moveDirection.x -= 1;
		
		moveDirection = moveDirection * (shieldSpeed * Time.deltaTime);
		
		newPosition = transform.position + moveDirection;
		
		newPosition.x = Mathf.Clamp(newPosition.x, -124, 124);
		
		transform.position = newPosition;
	}
}
